<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>轮盘</title>
    <style>
        div{
            --color:'red';
            background-color: var(--color);
        }
        #lottery{
            height: 4rem;
            width: 4rem;
            background: url('timg.jpg') no-repeat;
            background-size: 4rem 4rem; 
            position: absolute;
            top: 30%;
            left: 16%;
            transition-duration:3000ms;
        }
    </style>
</head>
<body>
    <input type="button" value="开始" id="start"/>
    <div id="lottery"></div>
    <script>
        /** 设定font-size 使用rem单位 */
        var screenWidth = window.screen.width;
        var fontSize = screenWidth/7.5 > 128 ? 128 : screenWidth/7.5;
        document.getElementsByTagName('html')[0].style.cssText = 'font-size:'+fontSize+'px';
        /** 点击事件 */
        var lastRotate = 1800;
        var lottery = document.getElementById('lottery');
        var start = document.getElementById('start');
        start.onclick = function(){
            var rotate = lastRotate;
            while(rotate > 360){
                rotate = Math.floor(Math.random()*1000);
            }
            rotate += lastRotate;
            lastRotate = rotate + 1800;
            lottery.style.cssText = 'transform: rotate('+(rotate)+'deg);';
        }
    </script>
</body>
</html>